package com.itheima.udp;

import java.io.IOException;
import java.net.*;

/**
 * @Author 王加鑫
 * @Date 2021/5/25 11:33
 * @Version 1.0
 */
public class Client01 {
    public static void main(String[] args) throws IOException {
        //创建Socket对象
        DatagramSocket ds = new DatagramSocket();

        //准备数据
        String s = "hello,组播!";
        byte[] bytes = s.getBytes();
        //组的ip地址
        InetAddress address = InetAddress.getByName("224.0.1.0");
        //创建packet对象
        DatagramPacket packet = new DatagramPacket(bytes,bytes.length,address,10001);
        //发送数据
        ds.send(packet);
        //关闭资源
        ds.close();
    }
}
